<template>
  <div>
    <div style="margin-bottom: 1rem;"></div>
    <!-- <BreakSpace label="维修项目列表" :containerStyle="{ marginBottom: '10px' }" /> -->
    <FilterTable
      ref="table"
      :columns="columns"
      :params="fetchParams"
      :fetchapi="fetchapi"
      :datakey="'records'"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      selectionType="single"
      :is-select-column="false"
      height="auto"
      :isPagination = true
    >
    </FilterTable>
    <Drawer :visible.sync="visibleEdit" :title="'索赔查看'" destroyOnClose width="100%" :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <editForm1 @close="editclose" @save="editsave" :rowData="rowData"></editForm1>
    </Drawer>
  </div>
</template>
<!--  getSpList  与索赔申请共用一个借口，通过工单号查询出所有的维修记录 -->
<script>
  import {  getSpList }  from '@/api/claim/dealer/ClaimApplication/index';
  import {  getAppId } from '@/assets/js/auth';
  import editForm1 from '../editForm1.vue';
  export default {
    // mixins: [dictionary],
      components: {
      editForm1
    },
    props:['vin'],
    data() {
      return {
        visibleEdit: false,
        dataList: [],
        dataList1: [],
        visible: false,
        visibleDrawer: false,
        collapse: false,
        infoId: null,
        // topFilterInit: this.topFilterInitFun(),
        flterValue: {}, //参数
        columns: this.creatHeader(),
        fetchapi: getSpList,
        fetchParams: { vin: this.vin, status: 4 }, //ipa 接口
        selectedRows: [], //选中经销商
        formList: this.createFormList(),
        saveData: null,
        rowData: {},
        activeName: '',
        menus: [
          {
            title: '审核记录',
            path: 'tabs/user',
            params: {
              type: 1
            }
          },
          {
            title: '维修历史',
            path: 'tabs/setting',
            disabled: true,
            params: {
              type: 2
            }
          }
        ]
      };
    },
    created() {
      console.log(this.dataList);
    },
    methods: {
      editclose() {
      this.visibleEdit = false;
      },
      editsave() {
      this.visibleEdit = false;
      this.fetchParams = { ...this.fetchParams };
    },
      createDictText(val){
        this.visibleEdit = true;
        this.rowData = val;
      },
      formChangeHandle(val) {
        console.log(val);
        this.saveData = val;
      },
      //搜索获取数据
      changeHandle(val) {
        this.fetchParams = Object.assign({}, this.fetchParams, val);
        console.log(val);
      },
      //选中
      selectChange(rows) {
        this.selectedRows = rows;
        console.log(this.selectedRows);
      },
      //保存
      saveDialog() {
        this.$refs.formPanel1.SUBMIT_FORM();
        if (this.saveData) {
          this.$emit('save', this.selectedRows);
        }
      },
      //取消操作
      closeDialog() {
        this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
      },
      chooseOrderNo() {
        this.visible = true;
      },
      add() {},
      createFormList() {
        return [
          {
            type: 'INPUT',
            label: '搜索',
            fieldName: 'title',
            placeholder: '请输入标题名称...',
            rules: [{ required: true, message: '请输入标题名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }],
            readonly: true // 只读
          },
          {
            type: 'SELECT',
            label: '所属分类',
            fieldName: 'cid',
            placeholder: '所属分类',
            itemList: [{ text: '热点', value: '1' }, { text: '资讯', value: '2' }],
            rules: [{ required: true, message: '请选择所属分类', trigger: 'change' }],
            disabled: true // 禁用
          },
          {
            type: 'DATE',
            label: '日期',
            fieldName: 'date',
            placeholder: '选择日期',
            rules: [{ required: true, message: '请选择日期', trigger: 'change' }]
          },
          {
            type: 'RANGE_DATE',
            label: '日期区间',
            style: { minWidth: '200px' },
            fieldName: 'startTime|endTime'
          },
          {
            type: 'MULTIPLE_SELECT',
            label: '兴趣爱好',
            fieldName: 'hobby',
            placeholder: '兴趣爱好',
            itemList: [{ text: '篮球', value: '1' }, { text: '足球', value: '2' }, { text: '乒乓球', value: '3' }],
            rules: [{ required: true, message: '请选择兴趣爱好', trigger: 'change' }]
          },
          {
            type: 'INPUT_NUMBER',
            label: '数量',
            fieldName: 'number',
            placeholder: '请输入数量...',
            initialValue: undefined,
            rules: [{ required: true, message: '请输入数量', trigger: 'blur' }]
          }
        ];
      },

      //table表头和数据源
      creatHeader() {
        return [
          {
            title: '序号',
            dataIndex: 'index',
            width: 80,
            sorter: true,
            render: props => {
              return <span>{props.row.index + 1}</span>;
            }
          },
          { title: '索赔单号', dataIndex: 'claimNo', sorter: true ,
         render: props => {
            if (getAppId() == 'beijing') {
               return (
                 <div>
                  <el-button size="mini" type="text" onClick={() => this.createDictText(props.row)} >
                  {props.row.claimNo}
                  </el-button>
                </div>
                );
            }else{
              return (
                <div>
                  {props.row.claimNo}
                </div>
                );
            }
          }},
          { title: '维修工单号', dataIndex: 'roNo', sorter: true },
          { title: '索赔经销商', dataIndex: 'ownerCode', sorter: true },
          { title: '索赔类型', dataIndex: 'cmsClaimTypeStr', sorter: true },
          { title: '申请日期', dataIndex: 'applyAt', sorter: true,dateFormat: 'yyyy-MM-dd' },
        ];
      },

    }
  };
</script>

<style lang="less" scoped></style>
